#pragma once
#include "Message.h"
#include "Util.h"
#include "CommonDefine.h"

class State;
class Object
{
public:
	virtual int HandleMessage(Object* pSender, MST eType, void* pExtData) = 0;
	virtual int Tick() = 0;
	int ChangeState(State* pNewState);

	int Init(string strName, int iHp)
	{
		m_strName = strName;
		m_iHp = iHp;
		return 0;
	}

	int GetObjectID() { return m_iObjectID; }
	void SetObjectID(int iObjectID) { m_iObjectID = iObjectID; }
	Point GetPostition() { return m_stPos; }
	void SetPostition(const Point& rPos) { m_stPos = rPos; }

	void SetHp(int iHp) { m_iHp = iHp; }
	int GetHp() { return m_iHp; }
	void CostHp(int iHp) 
	{ 
		m_iHp -= iHp;  
		if (m_iHp < 0)
		{
			m_iHp = 0;
		}
	}
	void AddHp(int iHp) { m_iHp += iHp; }
	bool IsDead() { return m_iHp <= 0; }

	const string& GetName() { return m_strName; }

	void SetState(State* pState) { m_pCurState = pState; }

protected:
	Point m_stPos;
	int m_iObjectID;
	int m_iHp;
	string m_strName;
	State* m_pCurState;
};